from django.db import models
from django.contrib.auth.models import AbstractUser

class Users(AbstractUser):
    mobile = models.CharField(max_length=11, verbose_name='手机号')

    class Meta:
        db_table = 'user'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

# 用户地址模型类
class Addr(models.Model):
    receiver = models.CharField('收件人',max_length=30)
    receiver_mobile = models.CharField('手机号',max_length=11)
    receiver_addr = models.CharField('收货地址',max_length=100)
    is_default = models.BooleanField('是否默认',default=False)
    user = models.ForeignKey(Users,on_delete=models.CASCADE,verbose_name='用户')
    class Meta:
        verbose_name = '收货地址'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.receiver_addr
